/*
ID: khymill1
PROG: runround 
LANG: C++
*/
#include <string.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>
#include <stdio.h>
#include <stdlib.h>



using namespace std;

bool check(int a)
{
    char buf[12];
    sprintf(buf,"%d",a);
    string str(buf);
    set<int> mySet;
    int next = 0;
    for (int i = 0; i < str.size(); i++) {
	if (mySet.count(str[next]-'0') != 0) return false;
	mySet.insert(str[next]-'0');
	next = (next + (str[next]-'0'))%str.size();
    }
    return true;
}


int main()
{
    ifstream fin("runround.in");
    ofstream fout("runround.out");
    int n, i;
    fin >> n;
    for (i = n; ; i++) {
	if (check(i))
	    break;
    }
    fout << i << endl;
    return 0;
}
